<?php
class Info_evModel extends Model {
	protected $_validate = array(
	    array('content','require','请填写标题！'),
    );
	protected $_auto = array(
        array('datetime','time',1,'function'),
    );
	
	public function _list($view,$map,$sort='sort',$pagesize=20){
		//计算总页数
		$count=$this->alias('ie')->count($map);
		//实例化分页类
		import ( 'ORG.Util.Page' );
		$p=new Page($count,$pagesize);
		$list = $this->alias('ie')->join("left join __INFO__ as i on i.id=ie.info_id")->Field('ie.*,i.title as info_title,i.id as info_id')->where($map)->order($sort)->limit($p->firstRow.',
'.$p->listRows)->select();
        $pages=$p->show();
		$view->assign('list',$list);
		$view->assign('pages',$pages);
	}
	
	//记录数
	public function count($map){
		$data = $this->where($map)->Field('count(*) as tp_count')->find();
		return $data['tp_count'];
	}
}